import sys

import command
import config


def git_init():
    get_config = config.get_config()
    name = get_config.get("git", "name")
    email = get_config.get("git", "email")

    if name is None or email is None:
        print("Please config git name and email address")
        sys.exit()

    if len(name) == 0 or len(email) == 0:
        print("Please config right git name and email address")
        sys.exit()

    command_line = ["git init",
                    f"git config user.name '{name}'",
                    f"git config user.email '{email}'"
                    ]
    command.exe_command(command_line)


if __name__ == '__main__':
    git_init()
